<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <!-- 定义受环境影响易变的变量 -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
        <property name="ignoreResourceNotFound" value="true"/>
        <property name="locations">
            <list>
                <value>classpath*:config/jdbc.properties</value>
            </list>
        </property>
    </bean>

    <!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
    <!-- 单数据源 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${r'${jdbc.driverClassName}'}'}'}"/>
        <property name="url" value="${r'${jdbc.url}'}"/>
        <property name="username" value="${r'${jdbc.username}'}"/>
        <property name="password" value="${r'${jdbc.password}'}"/>
        <property name="initialSize" value="${r'${dbcp.initialSize}'}"/>
        <property name="maxActive" value="${r'${dbcp.maxActive}'}"/>
        <property name="maxIdle" value="${r'${dbcp.maxIdle}'}"/>
        <property name="defaultAutoCommit" value="false"/>
    </bean>


    <bean id="manyDataSourceAspect" class="com.apache.database.datasource.DataSourceAspect"/>
    <aop:config>
        <aop:aspect id="manyDataSource" ref="manyDataSourceAspect">
            <aop:pointcut id="txDataSource"
                          expression="execution(* com.apache.api.api.ApiService.*(..))"/>
            <aop:before pointcut-ref="txDataSource" method="before"/>
        </aop:aspect>
    </aop:config>

    <!-- 多数据源配置stop -->

</beans>